{include file="public/header" /}
<style>
    .layui-form-label{width: 180px;margin-left: -55px}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox-title">
        <h5>联系我们</h5>
    </div>
    <div class="ibox-content layui-form">
        <div class="layui-row layui-col-space10 layui-form-item ">

            <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                <label class="layui-form-label">联系我们_英文：</label>
                <div class="layui-input-block" id="LAY_editor_en" lay-verify="editor">
                    <p>{$data.content_en}</p>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                <label class="layui-form-label">联系我们_西班牙：</label>
                <div class="layui-input-block" id="LAY_editor_es" lay-verify="editor">
                    <p>{$data.content_es}</p>
                </div>
            </div>

            <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                <label class="layui-form-label">联系我们_葡萄牙：</label>
                <div class="layui-input-block" id="LAY_editor_tp" lay-verify="editor">
                    <p>{$data.content_tp}</p>
                </div>
            </div>
            <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    var editor_en = wk.wang({elem:'#LAY_editor_en'}); // 英文
    var editor_es = wk.wang({elem:'#LAY_editor_es'}); // 西班牙
    var editor_tp = wk.wang({elem:'#LAY_editor_tp'}); // 葡萄牙
    layui.use(['form'], function() {
        var form = layui.form;
        form.verify({
            editor:function(value,item){
                if(!editor_en.txt.text()){
                    return '请填写英文联系我们';
                }
                if(!editor_es.txt.text()){
                    return '请填写西班牙语联系我们';
                }
                if(!editor_tp.txt.text()){
                    return '请填写葡萄牙语联系我们';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            data.field.content_en = editor_en.txt.html();
            data.field.content_es = editor_es.txt.html();
            data.field.content_tp = editor_tp.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('contactUs')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Projectconfig/contactUs')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>